package com.luck.redis;

import org.springframework.stereotype.Repository;

import java.lang.reflect.Proxy;
import java.util.List;

/**
 * 动态代理后的服务类
 * Created by Hua wb on 2018/11/16.
 */
@Repository
public class RedisProxyService implements RedisApi{

    RedisApi redisApi;

    public RedisProxyService(RedisService redisService) {
        this.redisApi = (RedisApi) Proxy.newProxyInstance(RedisApi.class.getClassLoader(),
                new Class[]{RedisApi.class}, new RedisProxy(redisService));
    }

    @Override
    public boolean isConnection() {
        return redisApi.isConnection();
    }

    @Override
    public void add(String key, String value) {
        redisApi.add(key, value);
    }

    @Override
    public String get(String key) {
        return redisApi.get(key);
    }

    @Override
    public void increase(String key, int number) {
        redisApi.increase(key, number);
    }

    @Override
    public void addList(String key, String value) {
        redisApi.addList(key, value);
    }

    @Override
    public void addList(String key, List<String> list) {
        redisApi.addList(key, list);
    }

    @Override
    public String pop(String key) {
        return redisApi.pop(key);
    }
}
